//
//  HNSH_SignGoodsExChangeRecordCell.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/4/23.
//

#import "HNSH_SignGoodsExChangeRecordCell.h"

@interface HNSH_SignGoodsExChangeRecordCell ()

/* bgView */
@property (nonatomic, strong) UIView *bgView;
/* imgV */
@property (nonatomic, strong) UIImageView *imgV;
/* titleLabel */
@property (nonatomic, strong) UILabel *titleLabel;
/* specLabel */
@property (nonatomic, strong) UILabel *specLabel;
/* countLabel */
@property (nonatomic, strong) UILabel *countLabel;
/* timeLabel */
@property (nonatomic, strong) UILabel *timeLabel;
/* priceLabel */
@property (nonatomic, strong) UILabel *priceLabel;

@end

@implementation HNSH_SignGoodsExChangeRecordCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor appBGColor];
        [self configView];
    }
    return self;
}

- (void)setModel:(HNSH_SignGoodsExChangeRecordModel *)model {
    [self.imgV sd_setImageWithURL:[NSURL URLWithString:model.left_icon]];
    self.titleLabel.text = model.title;
    self.specLabel.text = model.sku_text;
    
    self.countLabel.text = [NSString stringWithFormat:@"x%@",model.quantity];
    
    self.priceLabel.text = [NSString stringWithFormat:@"%@汇豆",model.bean_price];
    
    self.timeLabel.text = [NSString stringWithFormat:@"兑换时间：%@",model.exchange_time];
}

- (void)configView {
    [self addAllViews];
    [self addAllLayout];
}

- (void)addAllViews {
    [self.contentView addSubview:self.bgView];
    [self.bgView addSubview:self.imgV];
    [self.bgView addSubview:self.titleLabel];
    [self.bgView addSubview:self.specLabel];
    [self.bgView addSubview:self.countLabel];
    [self.bgView addSubview:self.priceLabel];
    [self.bgView addSubview:self.timeLabel];
}

- (void)addAllLayout {
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.right.mas_equalTo(-16);
        make.top.bottom.mas_equalTo(0);
    }];
    [self.imgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(self.contentView);
        make.width.height.mas_equalTo(96);
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(118);
        make.right.mas_equalTo(-10);
        make.top.equalTo(self.imgV.mas_top);
        make.height.mas_equalTo(22);
    }];
    
    [self.specLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(118);
        make.top.equalTo(self.titleLabel.mas_bottom).offset(0);
        make.height.mas_equalTo(17);
    }];
    
    [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(118);
        make.top.equalTo(self.specLabel.mas_bottom).offset(11);
        make.height.mas_equalTo(22);
    }];
    
    [self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.centerY.equalTo(self.priceLabel.mas_centerY);
        make.height.mas_equalTo(17);
    }];
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(118);
        make.right.mas_equalTo(-10);
        make.bottom.equalTo(self.imgV.mas_bottom);
        make.height.mas_equalTo(17);
    }];
    
    self.titleLabel.text = @"秘制糖汁百草梨膏  古法熬制";
    self.specLabel.text = @"50g/盒";
    self.priceLabel.text = @"135汇豆";
    self.countLabel.text = @"x3";
    self.timeLabel.text = @"兑换时间：2022.11.15 12:34:11";
}

#pragma mark lazy
- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [UIView new];
        _bgView.backgroundColor = [UIColor appWhiteLabelColor];
        _bgView.layer.cornerRadius = 8.0f;
        _bgView.layer.masksToBounds = YES;
    }
    return _bgView;
}
- (UIImageView *)imgV {
    if (!_imgV) {
        _imgV = [UIImageView new];
        _imgV.layer.cornerRadius = 8.0f;
        _imgV.layer.masksToBounds = YES;
    }
    return _imgV;
}
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.text = @"";
        _titleLabel.textColor = [UIColor appBlack333LabelColor];
        _titleLabel.font = [UIFont boldSystemFontOfSize:16];
    }
    return _titleLabel;
}
- (UILabel *)specLabel {
    if (!_specLabel) {
        _specLabel = [[UILabel alloc]init];
        _specLabel.text = @"";
        _specLabel.textColor = [UIColor colorWithHexString:@"#8E8E93"];
        _specLabel.font = [UIFont systemFontOfSize:12];
    }
    return _specLabel;
}
- (UILabel *)countLabel {
    if (!_countLabel) {
        _countLabel = [[UILabel alloc]init];
        _countLabel.text = @"x1";
        _countLabel.textColor = [UIColor colorWithHexString:@"#999999"];
        _countLabel.font = [UIFont systemFontOfSize:13];
    }
    return _countLabel;
}
- (UILabel *)timeLabel {
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc]init];
        _timeLabel.text = @"";
        _timeLabel.textColor = [UIColor colorWithHexString:@"#8E8E93"];
        _timeLabel.font = [UIFont systemFontOfSize:10];
    }
    return _timeLabel;
}
- (UILabel *)priceLabel {
    if (!_priceLabel) {
        _priceLabel = [[UILabel alloc]init];
        _priceLabel.text = @"--汇豆";
        _priceLabel.textColor = [UIColor colorWithHexString:@"#F45857"];
        _priceLabel.font = [UIFont boldSystemFontOfSize:16];
    }
    return _priceLabel;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
